﻿using MediatR;
using SystemMHB.API.Application.Command.LogisticsCommand;
using SystemMHB.Domian;
using SystemMHB.Infrstructer.Interface;

namespace SystemMHB.API.Application.CommandHandlers.LogisticsCommandHandler
{
    /// <summary>
    /// 物资信息反填中介者
    /// </summary>
    public class LogisticsFanCommandHandler:IRequestHandler<LogisticsFanCommand, Logistics>
    {
        /// <summary>
        /// 物资信息仓储接口
        /// </summary>
        ILogisticsReposiyory _logistics;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_logistics">物资信息仓储接口</param>
        public LogisticsFanCommandHandler(ILogisticsReposiyory _logistics)
        {
            this._logistics = _logistics;
        }

        public async Task<Logistics> Handle(LogisticsFanCommand request, CancellationToken cancellationToken)
        {
            var qouen = await _logistics.GetAllAsync();
            qouen.Where(p => p.purchaseNumber == request.purchaseNumber);
            Logistics lost = new Logistics();
            foreach (var item in qouen)
            {
                lost = item;
            }

            return lost;
        }
    }
}
